package cn.numeron.common.database

import androidx.room.TypeConverter
import java.util.*

class CommonTypeConverter {

    @TypeConverter
    fun Long?.fromTimestamp(): Date? {
        if (this == null || this < 0) {
            return null
        }
        return Date(this)
    }

    @TypeConverter
    fun Date?.dateToTimestamp(): Long {
        if (this == null) {
            return 0
        }
        return time
    }

}